def calculate_cpi_values(annual_inflation_rates: list) -> list:
    """Calculate the CPI values for each year based on the annual inflation rates."""
    cpi_values = [100]  # Assuming a base CPI of 100 for the first year
    for rate in annual_inflation_rates:
        new_cpi = cpi_values[-1] * (1 + rate / 100)
        cpi_values.append(new_cpi)
    return cpi_values


def calculate_inflation_adjusted_value_from_rates(initial_amount: float, annual_inflation_rates: list,
                                                  base_year_index: int, target_year_index: int) -> float:
    """Calculate the inflation-adjusted value of an amount from a past year to a target year using annual inflation rates."""
    cpi_values = calculate_cpi_values(annual_inflation_rates)
    base_cpi = cpi_values[base_year_index]
    target_cpi = cpi_values[target_year_index]

    adjusted_value = initial_amount * (target_cpi / base_cpi)
    return adjusted_value


# Example usage
initial_amount_example = 7500  # Initial amount in the base year (2010)
annual_inflation_rates_example = [3.18, 5.55, 2.62, 2.62, 1.92, 1.44, 2.00, 1.59, 2.07, 2.90, 2.42, 0.98,
                                  1.97]  # Inflation rates from 2010 to 2022
adjust_inflation_rates = [rate * 3 for rate in annual_inflation_rates_example]
base_year_index_example = 0  # Index of the base year (2010) in the inflation rates array
target_year_index_example = 12  # Index of the target year (2022) in the inflation rates array
if __name__ == '__main__':
    print(calculate_inflation_adjusted_value_from_rates(initial_amount_example, adjust_inflation_rates, base_year_index_example, target_year_index_example))

